<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.9.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('https://brady2037.github.io').hostname,
    root: '/',
    scheme: 'Gemini',
    version: '7.6.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
  };
</script>

  <meta name="description" content="升级3.0之后打开项目报错，这里记录一下解决的过程首先更新了gradle版本">
<meta name="keywords" content="技术,android,android studio">
<meta property="og:type" content="article">
<meta property="og:title" content="关于Android Studio3.0升级">
<meta property="og:url" content="https://brady2037.github.io/2017/10/27/关于Android-Studio3-0/index.html">
<meta property="og:site_name" content="Brady&#39;s Notes">
<meta property="og:description" content="升级3.0之后打开项目报错，这里记录一下解决的过程首先更新了gradle版本">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://oph0392na.bkt.clouddn.com/2017-10-27-屏幕快照 2017-10-27 15.48.27.png">
<meta property="og:updated_time" content="2019-07-25T02:13:14.844Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="关于Android Studio3.0升级">
<meta name="twitter:description" content="升级3.0之后打开项目报错，这里记录一下解决的过程首先更新了gradle版本">
<meta name="twitter:image" content="http://oph0392na.bkt.clouddn.com/2017-10-27-屏幕快照 2017-10-27 15.48.27.png">

<link rel="canonical" href="https://brady2037.github.io/2017/10/27/关于Android-Studio3-0/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true
  };
</script>

  <title>关于Android Studio3.0升级 | Brady's Notes</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?f055d42c8b60fddccdf87cf956d6d8e4";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Brady's Notes</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">Quick notes</p>
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="none"
           placeholder="搜索..." spellcheck="false"
           type="text" id="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://brady2037.github.io/2017/10/27/关于Android-Studio3-0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/uploads/avatar.png">
      <meta itemprop="name" content="Brady2037">
      <meta itemprop="description" content="Brady2037's Notes">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Brady's Notes">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          关于Android Studio3.0升级
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2017-10-27 14:45:16" itemprop="dateCreated datePublished" datetime="2017-10-27T14:45:16+08:00">2017-10-27</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-07-25 10:13:14" itemprop="dateModified" datetime="2019-07-25T10:13:14+08:00">2019-07-25</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/技术/" itemprop="url" rel="index">
                    <span itemprop="name">技术</span>
                  </a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/技术/android/" itemprop="url" rel="index">
                    <span itemprop="name">android</span>
                  </a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/技术/android/android-studio/" itemprop="url" rel="index">
                    <span itemprop="name">android studio</span>
                  </a>
                </span>
            </span>

          
            <span id="/2017/10/27/关于Android-Studio3-0/" class="post-meta-item leancloud_visitors" data-flag-title="关于Android Studio3.0升级" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h4 id="升级3-0之后打开项目报错，这里记录一下解决的过程"><a href="#升级3-0之后打开项目报错，这里记录一下解决的过程" class="headerlink" title="升级3.0之后打开项目报错，这里记录一下解决的过程"></a>升级3.0之后打开项目报错，这里记录一下解决的过程</h4><p>首先更新了gradle版本</p>
<img src="http://oph0392na.bkt.clouddn.com/2017-10-27-屏幕快照 2017-10-27 15.48.27.png" height="1269" width="585">

<a id="more"></a>

<p>之后报错</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Gradle sync failed: Cannot set the value of read-only property &apos;outputFile&apos; for ApkVariantOutputImpl_Decorated&#123;apkData=Main&#123;type=MAIN, fullName=xiaomiDebug, filters=[]&#125;&#125; of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.</span><br></pre></td></tr></table></figure>

<p>Google了一下，是因为项目Gradle下使用的部分代码语法变了<br>这是项目中原本自定义构建APK的代码</p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">applicationVariants.all &#123; variant -&gt;</span><br><span class="line">       variant.outputs.<span class="keyword">each</span> &#123; output -&gt;</span><br><span class="line">           <span class="keyword">def</span> newName</span><br><span class="line">           <span class="keyword">def</span> timeNow</span><br><span class="line">           <span class="keyword">def</span> outputFile = output.outputFile</span><br><span class="line">           <span class="keyword">if</span> (<span class="keyword">Boolean</span>.valueOf(IS_JENKINS)) &#123;</span><br><span class="line">               timeNow = JENKINS_TIME</span><br><span class="line">               newName = APP_PACKAGE_NAME + <span class="string">"-android-V$&#123;defaultConfig.versionName&#125;-"</span> + variant.productFlavors[<span class="number">0</span>].name + <span class="string">"-"</span> + timeNow + <span class="string">"-"</span> + variant.buildType.name + <span class="string">'.apk'</span></span><br><span class="line">           &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">               timeNow = getDate()</span><br><span class="line">               <span class="keyword">if</span> (<span class="string">'debug'</span> == variant.buildType.name) &#123;</span><br><span class="line">                   newName = APP_PACKAGE_NAME + <span class="string">"-android-V$&#123;defaultConfig.versionName&#125;-debug.apk"</span></span><br><span class="line">               &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                   newName = APP_PACKAGE_NAME + <span class="string">"-android-V$&#123;defaultConfig.versionName&#125;-"</span> + variant.productFlavors[<span class="number">0</span>].name + <span class="string">"-"</span> + timeNow + <span class="string">"-"</span> + variant.buildType.name + <span class="string">'.apk'</span></span><br><span class="line">               &#125;</span><br><span class="line">           &#125;</span><br><span class="line">           output.outputFile = <span class="keyword">new</span> <span class="keyword">File</span>(outDirectory, newName)</span><br><span class="line">       &#125;</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>

<p>其中的这句 <code>variant.outputs.each { output -&gt;</code><br>需要把<code>each</code>替换成<code>all</code><br>获取输出文件的代码<code>output.outputFile</code>已经变为只读,现在直接使用<code>outputFileName</code>赋值即可修改输出的名称</p>
<p>修改后的代码</p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">applicationVariants.all &#123; variant -&gt;</span><br><span class="line">        variant.outputs.all &#123; output -&gt;</span><br><span class="line">            <span class="keyword">def</span> newName</span><br><span class="line">            <span class="keyword">def</span> timeNow</span><br><span class="line">            <span class="keyword">if</span> (<span class="keyword">Boolean</span>.valueOf(IS_JENKINS)) &#123;</span><br><span class="line">                timeNow = JENKINS_TIME</span><br><span class="line">                newName = APP_PACKAGE_NAME + <span class="string">"-android-V$&#123;defaultConfig.versionName&#125;-"</span> + variant.productFlavors[<span class="number">0</span>].name + <span class="string">"-"</span> + timeNow + <span class="string">"-"</span> + variant.buildType.name + <span class="string">'.apk'</span></span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                timeNow = getDate()</span><br><span class="line">                <span class="keyword">if</span> (<span class="string">'debug'</span> == variant.buildType.name) &#123;</span><br><span class="line">                    newName = APP_PACKAGE_NAME + <span class="string">"-android-V$&#123;defaultConfig.versionName&#125;-debug.apk"</span></span><br><span class="line">                &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                    newName = APP_PACKAGE_NAME + <span class="string">"-android-V$&#123;defaultConfig.versionName&#125;-"</span> + variant.productFlavors[<span class="number">0</span>].name + <span class="string">"-"</span> + timeNow + <span class="string">"-"</span> + variant.buildType.name + <span class="string">'.apk'</span></span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            outputFileName = newName</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>修改后 Try Again 继续报错</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">Gradle sync failed: Cannot choose between the following configurations of project :androidSDK:</span><br><span class="line">			- debugApiElements</span><br><span class="line">			- debugRuntimeElements</span><br><span class="line">			- releaseApiElements</span><br><span class="line">			- releaseRuntimeElements</span><br><span class="line">			All of them match the consumer attributes:</span><br><span class="line">			- Configuration &apos;debugApiElements&apos;:</span><br><span class="line">			- Found com.android.build.api.attributes.BuildTypeAttr &apos;debug&apos; but wasn&apos;t required.</span><br><span class="line">			- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr &apos;Aar&apos; but wasn&apos;t required.</span><br><span class="line">			- Found com.android.build.gradle.internal.dependency.VariantAttr &apos;debug&apos; but wasn&apos;t required.</span><br><span class="line">			- Found org.gradle.api.attributes.Usage &apos;java-api&apos; but wasn&apos;t required.</span><br><span class="line">			- Configuration &apos;debugRuntimeElements&apos;:</span><br><span class="line">			- Found com.android.build.api.attributes.BuildTypeAttr &apos;debug&apos; but wasn&apos;t required.</span><br><span class="line">			- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr &apos;Aar&apos; but wasn&apos;t required.</span><br><span class="line">			- Found com.android.build.gradle.internal.dependency.VariantAttr &apos;debug&apos; but wasn&apos;t required.</span><br><span class="line">			- Found org.gradle... (show balloon)</span><br></pre></td></tr></table></figure>

<p>看报错说明是因为依赖的一个model<code>:androidSDK</code>,Google说明新版中依赖项目的语法改变了,依赖包使用旧的语法没有报错,<br>旧版<code>compile project(&#39;:androidSDK&#39;)</code><br>新版<code>implementation project(&#39;:androidSDK&#39;)</code><br>貌似现在依赖包也可以使用<code>implementation</code></p>
<p>这里还提示一点,gradle文件中:</p>
<p><code>compile</code> 替换为 <code>implementation</code><br> <code>apt</code> 替换为 <code>annotationProcessor</code><br> <code>testCompile</code> 替换为 <code>androidTestImplementation</code><br><code>releaseCompile</code> 替换为 <code>releaseImplementation</code></p>
<p>这里注意一点:<code>compile fileTree(dir: &#39;libs&#39;, include: [&#39;*.jar&#39;])</code><br>不需要替换<code>compile</code>,看样子只有依赖包的时候才需要替换<br>还有一点,有的依赖包替换成<code>implementation</code>提示找不到,换回<code>compile</code>又可以了</p>
<p>继续Tran Again提示需要更新Android SDK Build Tools version 至 26.0.2<br>之后报错</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Error:android-apt plugin is incompatible with the Android Gradle plugin.  Please use &apos;annotationProcessor&apos; configuration instead.</span><br><span class="line">Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html</span><br></pre></td></tr></table></figure>

<p>继续Google,新版去掉了android-apt,所以删除项目Gradle中<code>apply plugin: &#39;android-apt&#39;</code>,只保留<code>apply plugin: &#39;com.android.application&#39;</code><br>把<code>apt</code>替换为<code>annotationProcessor</code></p>
<p>Try Again:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html</span><br></pre></td></tr></table></figure>

<p>根据官网说法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">you need to first declare one or more dimensions using the flavorDimensions property. After that, assign each flavor to one of the dimensions you declared</span><br></pre></td></tr></table></figure>

<p>必须指定一个或多个 flavor dimensions<br>flavorDimensions 后面可以添加多个不同类型的参数例如：<code>flavorDimensions &quot;tier&quot;, &quot;minApi&quot;</code><br>官方示例:</p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Specifies two flavor dimensions.</span></span><br><span class="line">flavorDimensions <span class="string">"tier"</span>, <span class="string">"minApi"</span></span><br><span class="line"></span><br><span class="line">productFlavors &#123;</span><br><span class="line">     free &#123;</span><br><span class="line">      <span class="comment">// Assigns this product flavor to the "tier" flavor dimension. Specifying</span></span><br><span class="line">      <span class="comment">// this property is optional if you are using only one dimension.</span></span><br><span class="line">      dimension <span class="string">"tier"</span></span><br><span class="line">      ...</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    paid &#123;</span><br><span class="line">      dimension <span class="string">"tier"</span></span><br><span class="line">      ...</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    minApi23 &#123;</span><br><span class="line">        dimension <span class="string">"minApi"</span></span><br><span class="line">        ...</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    minApi18 &#123;</span><br><span class="line">        dimension <span class="string">"minApi"</span></span><br><span class="line">        ...</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>项目中原来的代码:</p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">productFlavors &#123;</span><br><span class="line">        _360 &#123;&#125;</span><br><span class="line">        xiaomi &#123;&#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<p>修改后的代码:</p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">flavorDimensions <span class="string">"default"</span></span><br><span class="line">productFlavors &#123;</span><br><span class="line">   _360 &#123;</span><br><span class="line">       dimension <span class="string">"default"</span></span><br><span class="line">   &#125;</span><br><span class="line">   xiaomi &#123;</span><br><span class="line">       dimension <span class="string">"default"</span></span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>继续Tran Again:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Error:found unexpected optical bounds (red pixel) on top border at x=102.</span><br><span class="line">Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details</span><br><span class="line">Error:Execution failed for task &apos;:ygj_new:merge_360DebugResources&apos;.</span><br><span class="line">&gt; Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details</span><br></pre></td></tr></table></figure>

<p>是因为项目.9图片中含有红色边线,删除即可</p>
<p>继续Try Again:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">FAILURE: Build failed with an exception.</span><br><span class="line"></span><br><span class="line">* What went wrong:</span><br><span class="line">Task &apos;compileDebug&apos; is ambiguous in root project &apos;eachonline_upgrade&apos;. Candidates are: &apos;compileDebugAidl&apos;, &apos;compileDebugAndroidTestAidl&apos;, &apos;compileDebugAndroidTestJavaWithJavac&apos;, &apos;compileDebugAndroidTestKotlin&apos;, &apos;compileDebugAndroidTestNdk&apos;, &apos;compileDebugAndroidTestRenderscript&apos;, &apos;compileDebugAndroidTestShaders&apos;, &apos;compileDebugAndroidTestSources&apos;, &apos;compileDebugJavaWithJavac&apos;, &apos;compileDebugKotlin&apos;, &apos;compileDebugNdk&apos;, &apos;compileDebugRenderscript&apos;, &apos;compileDebugShaders&apos;, &apos;compileDebugSources&apos;, &apos;compileDebugUnitTestJavaWithJavac&apos;, &apos;compileDebugUnitTestKotlin&apos;, &apos;compileDebugUnitTestSources&apos;.</span><br></pre></td></tr></table></figure>

<p>继续Tran Again:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Error:Execution failed for task &apos;:ygj_new:transformClassesWithAndroidGradleClassShrinkerFor_360Debug&apos;.</span><br><span class="line">&gt; java.lang.ArrayIndexOutOfBoundsException (no error message)</span><br></pre></td></tr></table></figure>

<p>对于这个错误真是百思不得其解,研究了两天在一篇博文的启示下把Instant Run关掉,之后就成功了!<br>这里附上这篇博文: <a href="http://www.jianshu.com/p/64c819e0d8a3" target="_blank" rel="noopener">记录使用Instant Run的一个坑</a></p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/技术/" rel="tag"># 技术</a>
              <a href="/tags/android/" rel="tag"># android</a>
              <a href="/tags/android-studio/" rel="tag"># android studio</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2017/10/20/Hexo新环境部署/" rel="prev" title="Hexo新环境部署">
      <i class="fa fa-chevron-left"></i> Hexo新环境部署
    </a></div>
      <div class="post-nav-item">
    <a href="/2017/10/30/关于mac下gradlew命令不能使用/" rel="next" title="关于mac下gradlew命令不能使用">
      关于mac下gradlew命令不能使用 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          
    <div class="comments" id="gitalk-container"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#升级3-0之后打开项目报错，这里记录一下解决的过程"><span class="nav-number">1.</span> <span class="nav-text">升级3.0之后打开项目报错，这里记录一下解决的过程</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Brady2037"
      src="/uploads/avatar.png">
  <p class="site-author-name" itemprop="name">Brady2037</p>
  <div class="site-description" itemprop="description">Brady2037's Notes</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">17</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">16</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">32</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/brady2037" title="GitHub → https://github.com/brady2037" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:lenk2037@foxmail.com" title="E-Mail → mailto:lenk2037@foxmail.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="http://weibo.com/lenk1111" title="Weibo → http://weibo.com/lenk1111" rel="noopener" target="_blank"><i class="fa fa-fw fa-weibo"></i>Weibo</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 2017 – 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Brady2037</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.6.0
  </div>

        






  <script>
  function leancloudSelector(url) {
    url = encodeURI(url);
    return document.getElementById(url).querySelector('.leancloud-visitors-count');
  }
  if (CONFIG.page.isPost) {
    function addCount(Counter) {
      var visitors = document.querySelector('.leancloud_visitors');
      var url = decodeURI(visitors.getAttribute('id'));
      var title = visitors.getAttribute('data-flag-title');

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length > 0) {
            var counter = results[0];
            Counter('put', '/classes/Counter/' + counter.objectId, { time: { '__op': 'Increment', 'amount': 1 } })
              .then(response => response.json())
              .then(() => {
                leancloudSelector(url).innerText = counter.time + 1;
              })
              .catch(error => {
                console.error('Failed to save visitor count', error);
              })
          } else {
              leancloudSelector(url).innerText = 'Counter not initialized! More info at console err msg.';
              console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \n However, you can still use LeanCloud without security, by setting `security` option to `false`.');
            
          }
        })
        .catch(error => {
          console.error('LeanCloud Counter Error', error);
        });
    }
  } else {
    function showTime(Counter) {
      var visitors = document.querySelectorAll('.leancloud_visitors');
      var entries = [...visitors].map(element => {
        return decodeURI(element.getAttribute('id'));
      });

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url: { '$in': entries } })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length === 0) {
            document.querySelectorAll('.leancloud_visitors .leancloud-visitors-count').forEach(element => {
              element.innerText = 0;
            });
            return;
          }
          for (let item of results) {
            let { url, time } = item;
            leancloudSelector(url).innerText = time;
          }
          for (let url of entries) {
            var element = leancloudSelector(url);
            if (element.innerText == '') {
              element.innerText = 0;
            }
          }
        })
        .catch(error => {
          console.error('LeanCloud Counter Error', error);
        });
    }
  }

  fetch('https://app-router.leancloud.cn/2/route?appId=62281P1xEWxoNFDT8fWdsT63-gzGzoHsz')
    .then(response => response.json())
    .then(({ api_server }) => {
      var Counter = (method, url, data) => {
        return fetch(`https://${api_server}/1.1${url}`, {
          method: method,
          headers: {
            'X-LC-Id': '62281P1xEWxoNFDT8fWdsT63-gzGzoHsz',
            'X-LC-Key': 'oGFMBFBPJS0zWhE8CxBGiaOc',
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      if (CONFIG.page.isPost) {
        if (CONFIG.hostname !== location.hostname) return;
        addCount(Counter);
      } else if (document.querySelectorAll('.post-title-link').length >= 1) {
        showTime(Counter);
      }
    });
  </script>


      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script>
<script src="/js/schemes/pisces.js"></script>
<script src="/js/next-boot.js"></script>



  




  <script src="/js/local-search.js"></script>












  

  

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
NexT.utils.loadComments(document.querySelector('#gitalk-container'), () => {
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', () => {
    var gitalk = new Gitalk({
      clientID: '2731edd78c3655ec89ba',
      clientSecret: 'e0162eafff940b04de430791da9fa19d42509259',
      repo: 'brady2037.github.io',
      owner: 'brady2037',
      admin: ['brady2037'],
      id: '7e52e6123c4bfaa76c57251150210ba6',
        language: 'zh-CN',
      distractionFreeMode: true
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
});
</script>

</body>
</html>
